package main

import (
	"awesome/model"
	"awesome/user"
	"fmt"
	"github.com/gin-gonic/gin"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

func main1234() {
	dsn := "root:root@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local"
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	model.DB = db
	if err != nil {
		panic(err)
	}
	//自动迁移
	db.AutoMigrate(&model.User{})
	db.AutoMigrate(&model.Shop{})
	db.AutoMigrate(&model.AvatarStore{})
	db.AutoMigrate(&model.AvatarCategory{})
	db.AutoMigrate(&model.AvatarStoreCategory{})
	db.AutoMigrate(&model.Order{})
	db.AutoMigrate(&model.CreditCard{})

	r := gin.Default()
	r.POST("/users", user.Getusers)
	r.POST("/categories", user.Getcategories)
	r.POST("/avatar", user.Getavatar)
	fmt.Println("服务器运行起来了")

	r.Run(":8001")

}
